<?php
include DOCMENT_ROOT.'/Framework/model.class.php';
class newModel extends model{
   public function __construct(){
       parent::connectMysqlDB("zuoye");
    }
        public function newList($order="id desc",$num=5,$start=0){
        $sql = "select * from new order by $order limit $start,$num";//拼接sql语句
        $arr = $this->mysql->select($sql);//查询
        return $arr;//返回结果
    }
    public function newCount(){
        $sql="select count(*) as num from new";   //查询总条数
        $arr = $this->mysql->select($sql);
        $count = 0;
        if(!empty($arr)) {
            $count = $arr[0]["num"];
        }
        return $count;
    }
     //增加
    public function newadd($title,$content){
        $time=date("Y-m-d H:i:s");
        $sql="insert into new(title,content,add_time,click) values ('$title','$content','$time','0')";
        $arr = $this->mysql->add($sql);
        return $arr;
    }
  
    public function newContent($where){
        $sql = "select * from new where $where";   //查询
       $arr = $this->mysql->select($sql);
        $row = mysqli_fetch_assoc($arr);
        return $row;
    }
      public function newClick($where){
      $sql= "update new set click = click+1 where {$where}";  //点击+1
        $arr = $this->mysql->add($sql);
        return $arr; 
    }
   
}
